package com.example.yadmin.sys.service.impl;

import com.example.yadmin.sys.entity.Goods;
import com.example.yadmin.sys.entity.User;
import com.example.yadmin.sys.mapper.GoodsMapper;
import com.example.yadmin.sys.service.IGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ag
 * @since 2023-10-13
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public void addGoods(Goods goods) {
        this.baseMapper.insert(goods);
    }

    @Override
    public void deleteGoodsById(Integer id) {
        this.baseMapper.deleteById(id);
    }

    @Override
    public void updateGoods(Goods goods) {
        this.baseMapper.updateById(goods);
    }

    @Override
    public Goods getGoodsById(Integer id) {
        Goods goods = this.baseMapper.selectById(id);
        return goods;
    }

    @Override
    public List<Goods> getGoodsInfoByUsername(String username) {
        List<Goods> goodsList = this.baseMapper.getGoodsListInfoByUsername(username);
        return goodsList;
    }

    @Override
    public List<User> getUserListInfoByOwner(String goodsOwner) {
        List<User> userList = this.baseMapper.getUserListInfoByOwner(goodsOwner);
        return userList;
    }


}
